<template>
  <div>

    <van-cell @click="clickFn">
        <!-- title -->
      <template #title>
        <div class="title-box">
          <span>{{item.title}}</span>
           <!-- 数据库单张图片 -->
           <img
           v-if="item.cover.type===1"
           v-lazy="item.cover.images[0]"
           class="thumb">
        </div>
        <!-- 数据库多张图片 -->
        <div class="thumb-box"  v-if="item.cover.type>1">
            <img
            v-for="img,index in item.cover.images" :key="index"
            v-lazy="img"
             class="thumb">
        </div>
      </template>

      <!-- label -->
      <template #label>
        <div class="label-box">
          <div>
              作者: <span>{{item.aut_name}}</span>&nbsp;&nbsp;
                    <span>{{item.comm_count}}评论</span>&nbsp;&nbsp;
          发布日期: <span>{{item.pubdate}}</span></div>

         <van-icon name="cross" @click.stop="crossFn" v-if="boolean"/>
          </div>
      </template>
    </van-cell>
    <!-- 底部反馈面板 -->
    <van-action-sheet v-model="show" :actions="actions" @select="onSelect" :cancel-text="cancelText" get-container="body" @cancel="cancelFn"/>
  </div>
</template>

<script>
import { firstActions, secondActions } from '@/api/report.js'

export default {
  data () {
    return {
      show: false, // 底部反馈面板是否显示
      actions: firstActions,
      cancelText: '取消'
    }
  },
  methods: {
    onSelect (action, index) {
      if (action.name === '反馈垃圾内容') {
        this.actions = secondActions
        this.cancelText = '返回'
      } else if (action.name === '不感兴趣') {
        this.$emit('delFn', this.item, action)
        this.show = false
      } else if (action.name === '拉黑作者') {

      } else {
        this.$emit('delFn', this.item, action)
      }
    },
    cancelFn () {
      this.cancelText = '取消'
      this.actions = firstActions
      setTimeout(() => { this.show = true })
    },
    crossFn () {
      this.show = true// 底部反馈面板出现
    },
    clickFn () {
      this.$router.push({ path: `/articleDetail?aid=${this.item.art_id}` })
    }
  },
  props: {
    item: {
      type: Object,
      required: true
    },
    boolean: {
      type: Boolean,
      default: true
    }
  }
}
</script>
<style lang="less" scoped>

.title-box{
display: flex;
justify-content: space-between;
align-items: flex-start;
}

// label
.label-box{
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 图片的样式, 矩形黄金比例：0.618 */
.thumb {
  width: 113px;
  height: 70px;
  background-color: #f8f8f8;
  object-fit: cover;
}

/* 三图, 图片容器 */
.thumb-box {
  display: flex;
  justify-content: space-between;
}

</style>
